﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;
using Castle.Windsor;
using SuppKids.Core.Providers;
using SuppKids.IoC.Installers;
using SuppKids.ViewModels;

namespace SuppKids.IoC
{
	public static class WindsorContainerExtensions
	{
		public static IWindsorContainer RegisterComponents(this IWindsorContainer container)
		{
			container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
			container.Register(Component.For<IWindsorContainer, WindsorContainer>().Instance(container));
			container.Register(Component.For<IApplicationSettingsProvider>().ImplementedBy<ApplicationSettingsProvider>().LifestyleSingleton());
			container.Install(
				new RepositoriesInstaller(),
				new ReportGeneratorsInstaller(),
				new ServicesInstaller(),
				new SecurityInstaller(),
				new WindowsInstaller());
			container.Register(Component.For<LicenseService>().ImplementedBy<LicenseService>().LifestyleSingleton());
			return container;
		}
	}
}
